{extend name="base" /}
{block name="main"}
<div class="tpl-content-wrapper">
    <div class="tpl-content-page-title">
        角色列表
    </div>
    <ol class="am-breadcrumb">
        <li><a href="{:url('admin/Index/index')}" class="am-icon-home">首页</a></li>
        <li class="am-active">权限管理</li>
        <li class="am-active">角色列表</li>
    </ol>
    <div class="tpl-portlet-components">
        <div class="portlet-title">
            <div class="caption font-green bold">
                <span class="am-icon-code"></span> 列表
            </div>



        </div>
        <div class="tpl-block">
            <div class="am-g">
                <div class="am-u-sm-12 am-u-md-6">
                    <div class="am-btn-toolbar">
                        <div class="am-btn-group am-btn-group-xs">
                            <a href="{:url('admin/Role/create')}" class="am-btn am-btn-default am-btn-success"><span class="am-icon-plus"></span> 新增</a>

                        </div>
                    </div>
                </div>


            </div>
            <div class="am-g">
                <div class="am-u-sm-12">
                    <form class="am-form">
                        <table class="am-table am-table-striped am-table-hover table-main am-table-centered">
                            <thead>
                            <tr>
                                <th class="table-check"><input type="checkbox" class="tpl-table-fz-check"></th>
                                <th class="table-id">ID</th>
                                <th class="table-date am-hide-sm-only">角色</th>
                                <th class="table-date am-hide-sm-only">描述</th>
                                <th class="table-date am-hide-sm-only">状态</th>
                                <th class="table-set">操作</th>
                            </tr>
                            </thead>
                            <tbody>
                            {volist name='data' id='role'}
                            <tr>
                                <td><input type="checkbox"></td>
                                <td>{$role.id}</td>
                                <td>{$role.name}</td>
                                <td>{$role.remark}</td>
                                {if $role.status==1}
                                <td class="am-hide-sm-only"><a class="u-status" u-status="{$role.status}" u-uid="{$role.id}">激活</a></td>
                                {else}
                                <td class="am-hide-sm-only"><a style="color: #93a2a9" class="u-status" u-status="{$role.status}" u-uid="{$role.id}">禁用</a></td>
                                {/if}
                                <td>
                                    <div class="">
                                        <div class="am-btn-group am-btn-group-xs">
                                            <a href="{:url('admin/Role/edit',['id'=>$role.id])}" class="am-btn am-btn-default am-btn-xs fff"><span class="am-icon-pencil-square-o"></span> 编辑</a>
                                            <a href="{:url('admin/Role/read',['id'=>$role.id])}" class="am-btn am-btn-default am-btn-xs am-hide-sm-only fff"><span class="am-icon-copy"></span> 给角色分配节点</a>
                                            <button type="button" class="am-btn am-btn-default am-btn-xs am-text-danger am-hide-sm-only btn-del" iddata="{$role.id}"><span class="am-icon-trash-o"></span> 删除角色</button>
                                        </div>
                                    </div>
                                </td>
                            </tr>
                            {/volist}
                            </tbody>
                        </table>
                        <div class="am-cf">

                            <div class="am-fr">
                                    {$data->render()}
                            </div>
                        </div>
                        <hr>

                    </form>
                </div>

            </div>
        </div>
        <div class="tpl-alert"></div>
    </div>

    <script>
        $(function () {
            $('.btn-del').click(function(){
                var id = $(this).attr('iddata');
                var obj = $(this).parents('tr');
//                console.log($(this).attr('iddata'))
                if(confirm('你确定要删除该角色吗')){
                    delajax(id,obj,'role');
                    $('.rolecount').html($('.rolecount').html()-1);
                }
            })

            var $ustu = $('.u-status');
            $ustu.click(function(){
                var uid = $(this).attr('u-uid');
                var stu = $(this).attr('u-status');
                var obj = $(this);
//           console.log(stu);
                csajax(uid,stu,obj,'/admin/Role/changestatus');

            })
        })
    </script>








</div>
{/block}